/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package treeship.core.ship.space;

/**
 *
 * @author Moonchild
 */
public abstract class Shape {

    private Space dimension;
    private Space freespace;

    public abstract Position adjustPositionForInnerShape(Position newPos, Shape shape);

    public Space getDimension() {
        return dimension;
    }

    protected void setDimension(Space dimension) {
        this.dimension = dimension;
    }

    public void initShape(Space dimension) {
        setDimension(dimension);
        custom_initShape(dimension);
    }

    public Space getFreespace() {
        return freespace;
    }

    public void setFreespace(Space freespace) {
        this.freespace = freespace;
    }

    public abstract boolean fitsIn(Shape s);

    protected boolean dimensionFitsInOtherFreespace(Shape s) {
        if (s.getFreespace().isBiggerOrEqualThan(this.getDimension())) {
            return true;
        }
        return false;
    }

    /**
     * Hook for subclasses
     * @param dimension
     */
    protected void custom_initShape(Space dimension) {
    }

    public abstract boolean contains(Position p);
}
